package com.mymvc.controller.param;

import com.mymvc.VO.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.stream.Stream;

/**
 * ClassName: UserController
 * Package: com.mymvc.controller.param
 * Description:
 *
 * @Author 刘英杰
 * @Create 2025/2/8 20:32
 * @Version 1.0
 */

@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/list.do")
    public String list(HttpServletRequest request, HttpServletResponse response, HttpSession session,
                       Model model) {
        request.setAttribute("name","aaa");
        model.addAttribute("age","bbb");
        session.setAttribute("gender","man");

        return "userList";
    }



    @PostMapping("/submitBaseType.do")
    public String submitBaseType(@RequestParam("name") String username, String password) {
        System.out.println(username + password);
        return "success";
    }

    @PostMapping("/submitVO.do")
    public String submitVO(User user) {
        System.out.println(user);
        return "success";
    }

    @PostMapping("/submitVO02.do")
    public String submitVO02(User user) {
        System.out.println(user);
        return "success";
    }

    @PostMapping("/submitArrays.do")
    public String submitArrays(String[] hobby) {
        Stream.of(hobby).forEach(System.out::println);
        return "success";
    }
}
